#!/usr/bin/env python3

import numpy as np
import cv2 as cv

gx = 0.0


def on_trackbar(x):
    global gx
    gx = float(x / 10.0)
    print(gx)


img1 = cv.imread('../pic/7.png')
img2 = cv.imread('../pic/12_568*442.png')
print("img1.shape:", img1.shape)
print("img2.shape:", img2.shape)

cv.namedWindow("dst")
cv.createTrackbar('W', 'dst', 0, 10, on_trackbar)

# add 具有透明效果
dst = cv.add(img1, img2)
# 显示结果
cv.imshow('dst', dst)
cv.waitKey(0)

while True:
    # 图片尺寸需要一致
    dst = cv.addWeighted(img1, gx, img2, 1.0 - gx, 0)
    cv.imshow('dst', dst)
    k = cv.waitKey(10) & 0xFF
    if k == 27:
        break

cv.destroyAllWindows()
